package com.ldcc.report_system.component;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.ldcc.report_system.R;

/**
 * @author wwj[yeshengkele@outlook.com]
 * @description 用户信息列表控件
 */
public class UserInfoItemLayout extends LinearLayout {
    private TextView infoText;
    private TextView infoValue;

    public UserInfoItemLayout(Context context) {
        this(context, null);
    }

    public UserInfoItemLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.user_info_item, this);
        this.infoText = findViewById(R.id.info_text);
        this.infoValue = findViewById(R.id.info_value);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.user_info_item_value);
        this.infoText.setText(typedArray.getString(R.styleable.user_info_item_value_userInfo));
        this.infoValue.setText(typedArray.getString(R.styleable.user_info_item_value_userValue));
        typedArray.recycle();
    }

    /**
     * @param userInfoItemLayout 用户组件
     * @param valueText          设置的值
     */
    public static void setUserInfoItemValueText(UserInfoItemLayout userInfoItemLayout, String valueText) {
        TextView viewById = userInfoItemLayout.findViewById(R.id.info_value);
        viewById.setText(valueText == null || "null".equals(valueText) ? "-" : valueText);
    }


    public TextView getInfoText() {
        return infoText;
    }

    public void setInfoText(TextView infoText) {
        this.infoText = infoText;
    }

    public TextView getInfoValue() {
        return infoValue;
    }

    public void setInfoValue(TextView infoValue) {
        this.infoValue = infoValue;
    }
}
